<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib  prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib  prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib  prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>

<c:set var="ctx" value="${pageContext.request.contextPath}" />  
<!doctype html> 
<html lang="zh-CN">
	<head>
		<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
		<meta charset="utf-8"/>
		<meta http-equiv="Cache-Control" content="no-store" />
		<meta http-equiv="Pragma" content="no-cache" />
		<meta http-equiv="Expires" content="0" />
		
	    <link href="${ctx}/static/css/report.css" rel="stylesheet" type="text/css" media="screen" />
	    <style type="text/css">
	    	table.indicatorSourceTable{
	    		border: 1px solid #000; 
	    		border-spacing: 0;
				border-collapse: collapse;
				width:350px;
	    	}
	    	
	    	table.indicatorSourceTable td{
	    		border: 1px solid #000; 
	    		height:40px;
	    	}
	    </style>
	</head>
	<body>
		   <div style="height: 300px;width: 100%;overflow: scroll;border: 1px solid #000;">
		   		<h4>上报报表</h4>
		   		${statResult.originalReportHtml }
		   </div>
		   <div id="statResult" style="height: 300px;width: 100%;overflow: scroll;border: 1px solid #000;">
		   		<h4>下属部门汇总报表</h4>
		   		${statResult.statReportHtml }
		   </div>
	</body>
<script  type="text/javascript" src="${ctx}/static/jquery/jquery-1.8.3.js"></script>
<script src="${ctx}/static/artDialog/jquery.artDialog.js?skin=default"></script>

<script type="text/javascript">
	$('#report-body td input[type="text"]').each(function(i){
		var thisVal = $(this).val();
		$(this).parent().empty().text(thisVal);
	});
	
	$('body').find('div[id="report-foot"]').remove();
	
	$('#statResult').find('div[id="report-head"]').remove();
	
	var reportStatVO = ${reportStatVO};
	var reportType = ${reportType};
	$('#statResult td.indicatorCell').on('click',function(){
		$this = $(this);
		var indicatorId = $this.attr('indicatorid');
		reportStatVO.indicatorId = indicatorId;
		//行式列表需要获取主列值
		if(reportType.dataType == 2){
			var masterColumnValue = $(this).parents('tr').find('td:eq(' + (reportType.masterColumn - 1) + ')').text();
			reportStatVO.masterColumnValue = masterColumnValue;
		}
		$.ajax({
			url : 'service.do?method=reportStatSource',
			data : reportStatVO,
			type : 'POST',
			dataType  : 'json'
		}).done(function(data){
			var dialogContent = '<table class="indicatorSourceTable">';
			for(var i = 0; i < data.length;i++){
				var row = data[i];
				dialogContent += '<tr>';
				dialogContent += '<td>' + row[0] + '</td>';
				dialogContent += '<td>' + row[1] + '</td>';
				dialogContent += '</tr>';
			}
			dialogContent += '</table>';
			$.dialog({
			    content: dialogContent
			});

		}).fail(function(data){
			alert(data);
		});
	});
</script>
</html>
    